package com.huohuzhihui.web.controller.merchant;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.huohuzhihui.common.annotation.Log;
import com.huohuzhihui.common.core.controller.BaseController;
import com.huohuzhihui.common.core.domain.AjaxResult;
import com.huohuzhihui.common.enums.BusinessType;
import com.huohuzhihui.merchant.domain.MerActivityBrowse;
import com.huohuzhihui.merchant.service.IMerActivityBrowseService;
import com.huohuzhihui.common.utils.poi.ExcelUtil;
import com.huohuzhihui.common.core.page.TableDataInfo;

/**
 * 活动浏览记录Controller
 * 
 * @author huohuzhihui
 * @date 2021-04-06
 */
@RestController
@RequestMapping("/merchant/activitybrowse")
public class MerActivityBrowseController extends BaseController
{
    @Autowired
    private IMerActivityBrowseService merActivityBrowseService;

    /**
     * 查询活动浏览记录列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:activitybrowse:list')")
    @GetMapping("/list")
    public TableDataInfo list(MerActivityBrowse merActivityBrowse)
    {
        startPage();
        List<MerActivityBrowse> list = merActivityBrowseService.selectMerActivityBrowseList(merActivityBrowse);
        return getDataTable(list);
    }

    /**
     * 导出活动浏览记录列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:activitybrowse:export')")
    @Log(title = "活动浏览记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MerActivityBrowse merActivityBrowse)
    {
        List<MerActivityBrowse> list = merActivityBrowseService.selectMerActivityBrowseList(merActivityBrowse);
        ExcelUtil<MerActivityBrowse> util = new ExcelUtil<MerActivityBrowse>(MerActivityBrowse.class);
        return util.exportExcel(list, "activitybrowse");
    }

    /**
     * 获取活动浏览记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:activitybrowse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(merActivityBrowseService.selectMerActivityBrowseById(id));
    }

    /**
     * 新增活动浏览记录
     */
    @PreAuthorize("@ss.hasPermi('merchant:activitybrowse:add')")
    @Log(title = "活动浏览记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerActivityBrowse merActivityBrowse)
    {
        return toAjax(merActivityBrowseService.insertMerActivityBrowse(merActivityBrowse));
    }

    /**
     * 修改活动浏览记录
     */
    @PreAuthorize("@ss.hasPermi('merchant:activitybrowse:edit')")
    @Log(title = "活动浏览记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerActivityBrowse merActivityBrowse)
    {
        return toAjax(merActivityBrowseService.updateMerActivityBrowse(merActivityBrowse));
    }

    /**
     * 删除活动浏览记录
     */
    @PreAuthorize("@ss.hasPermi('merchant:activitybrowse:remove')")
    @Log(title = "活动浏览记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(merActivityBrowseService.deleteMerActivityBrowseByIds(ids));
    }
}
